package com.neusoft.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.po.Food;

@Mapper
public interface FoodMapper {
	
	@Insert("insert into food(foodName,foodExplain,foodImg,foodPrice,businessId,deleted) values(#{foodName},#{foodExplain},#{foodImg},#{foodPrice},#{businessId},0)")
	@Options(useGeneratedKeys=true,keyProperty = "foodId",keyColumn="foodId")
	public int saveFood(Food food);
	
	// 根据商家编号查询所属食品信息
	@Select("select * from food where businessId=#{businessId} and deleted=0 order by foodId")
	public List<Food> listFoodByBusinessId(Integer businessId);

	// 根据食品编号查询食品信息
	public Food getFoodById(Integer foodId);

	@Update("update food set deleted=1 where foodId=#{foodId}")
	public int updateFoodStatus(Integer foodId);
}